package com.virgo.mysql.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.virgo.common.utils.ITimeUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

@Component
public class MybatisPlusMetaHandler implements MetaObjectHandler {

	@Override
	public void insertFill(MetaObject metaObject) {
		long nowTime = ITimeUtils.gmTime();
		this.setFieldValByName("createdAt", nowTime, metaObject);
		this.setFieldValByName("updatedAt", nowTime, metaObject);
	}

	@Override
	public void updateFill(MetaObject metaObject) {
		long nowTime = ITimeUtils.gmTime();
		this.setFieldValByName("updatedAt", nowTime, metaObject);
	}
}
